﻿@model Sanpham

<h2>Quản lý Sản Phẩm</h2>

<div class="row">
    <div class="col-md-8">

        @using (Html.BeginForm("Index", "Sanpham", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
        {
            <hr />
            @Html.ValidationSummary(true)
           <div> @ViewBag.xem </div>
            <div class="form-group">
                @Html.Label("Id", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Id, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Id)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Loại", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.DropDownList("LoaiId", null, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Tên sản phẩm", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Tensanpham, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Tensanpham)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Quy cách", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Quycach, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Quycach)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Số lần xem", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Solanxem, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Solanxem)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Chất liệu", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Chatlieu, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Chatlieu)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Giá", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Gia, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Gia)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Hình sản phẩm", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">

                    <input type="file" name="hinh" />
                    @Html.HiddenFor(m => m.Hinh)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Đố", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Do, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Do)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Mặt trên", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Mattren, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Mattren)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Mặt dưới", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.TextBoxFor(m => m.Matduoi, new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.Matduoi)
                </div>

            </div>
            <div class="form-group">
                @Html.Label("Hàng mới", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    @Html.CheckBoxFor(m => m.Hangmoi, new { @class = "form-control" })

                </div>
            </div>
            <div class="form-group container">
                @Html.Label("        ", new { @class = "col-md-5 control-label" })
                <div class="col-md-7">
                    <input type="submit" value="Thêm" onclick="form.action='/Admin/Sanpham/Them'" class="btn btn-default" />
                    <input type="submit" value="Cập nhật" onclick="form.action = '/Admin/Sanpham/Capnhat'" class="btn btn-default" />
                    <a href="/Admin/Sanpham/Xoa/@Model.Id" class="btn btn-default">Xóa</a>
                    <a href="/Admin/Sanpham/Index" class="btn btn-default">Hủy</a>

                </div>
            </div>


        }

    </div>

</div>
<hr />
<h2>Danh sách sản phẩm hiện có</h2>
<table class="table table-bordered table-hover ">
    <tr>
        <th class="panel-heading">Id</th>
        <th class="panel-heading">Loại Id</th>
        <th class="panel-heading">Tên loại</th>
        <th class="panel-heading">Tên sản phẩm</th>
        <th class="panel-heading">Quy cách</th>
        <th class="panel-heading">Chất liệu</th>
        <th class="panel-heading">Giá</th>
        <th class="panel-heading">Hình</th>
        <th class="panel-heading">Đố</th>
        <th class="panel-heading">Mặt trên</th>
        <th class="panel-heading">Mặt dưới</th>
        <th class="panel-heading">Hàng mới</th>
        <th class="panel-heading">Số lần xem</th>
        <th>                    </th>
    </tr>
    @foreach (Sanpham c in ViewBag.sanpham)
    {
        <tr>
            <td>@c.Id</td>
            <td>@c.LoaiId</td>
            <td>@c.Loai.Tenloai</td>
            <td>@c.Tensanpham</td>
            <td>@c.Quycach</td>
            <td>@c.Chatlieu</td>
            <td>@c.Gia</td>
            <td>@c.Hinh</td>
            <td>@c.Do</td>
            <td>@c.Mattren</td>
            <td>@c.Matduoi</td>
            <td>@c.Hangmoi</td>
            <td>@c.Solanxem</td>
            
            <td>
                <a href="/Admin/Sanpham/Sua/@c.Id" class="btn btn-default">Sửa</a>
                <a href="/Admin/Sanpham/Xoa/@c.Id" class="btn btn-default">Xóa</a>
            </td>
        </tr>
    }
</table>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}